﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="XWord.Fundamental.Domain" namespace="XWord.Fundamental.Domain">

  <class name ="Etyma" dynamic-update="true">
    <id name="Id" column="Id">
      <generator class="guid.comb"/>
    </id>
    <discriminator column="EtymaType" not-null="true"/>

    <many-to-one name="Category" class="Category" column="CategoryId" />
    <set name="Words" table="EtymaWord" lazy="true">
      <key column="EtymaId"/>
      <many-to-many column="WordId"
       unique="false"
       class="Word"/>
    </set>
    <property name="Name"/>
    <property name="Comment"/>
    
    <!--前缀-->
    <subclass name ="PreFix" discriminator-value="XWord.Fundamental.Domain.PreFix" dynamic-update="true">
      
    </subclass>
    <!--词根-->
    <subclass name ="Etymon" discriminator-value="XWord.Fundamental.Domain.Etymon" dynamic-update="true">

      <many-to-one name="Parent" class="Etymon" column="ParentId" cascade="all-delete-orphan"/>

      <set name="Children" cascade="all-delete-orphan">
        <key column="ParentId" foreign-key="FK_Etymon_ParentEtymon"/>
        <one-to-many class="Etymon"/>
      </set>
      
    </subclass>
    <!--后缀-->
    <subclass name ="Suffix" discriminator-value="XWord.Fundamental.Domain.Suffix" dynamic-update="true">

    </subclass>
  </class>

</hibernate-mapping>